home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: mxsld2.pd.infn.it!LORETI
- From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
- Subject: Re: start array at k, not 0
- X-Nntp-Posting-Host: mxsld2.pd.infn.it
- Message-ID: <DKwoyx.MD@news.cern.ch>
- Sender: news@news.cern.ch (USENET News System)
- Reply-To: loreti@mxsld2.pd.infn.it
- Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
- References: <Pine.OSF.3.91.960104095358.22268B-100000@io.UWinnipeg.ca> <820787486snz@genesis.demon.co.uk> <Pine.OSF.3.91.960105091211.2861B-100000@io.UWinnipeg.ca> <4cpdt3$3b5@newdelph.cig.mot.com> <30f06d21.167303296@nntp.ix.netcom.com>,<tbutler.821142000@laraby.tiac.net>
- Date: Tue, 9 Jan 1996 08:58:56 GMT
-
- In article <tbutler.821142000@laraby.tiac.net>, tbutler@laraby.tiac.net (Tim Butler) writes:
- >miker3@ix.netcom.com (Mike Rubenstein) writes:
- >[ Numerical Recipes method of array indexing referenced ]
- >.....
- >:It's unfortunate that the authors of this book didn't bother to learn
- >:C before writing it. As anyone who has read the FAQ [6.13] knows,
- >:this results in undefined behavior.
- >....
- >
- >They have addressed that in the second edition. To retain the ability
- >to start indexing at one, they "waste" that first element. They
- >allocate one element extra.
- >
- >--
- >tim butler
- >tbutler@tiac.net
-
- Sorry, wrong. From the second edition, 1992 (ISBN 0-521-43108-5),
- page 19 (emphasis on PERVERSELY mine):
-
- "But suppose that your vector of length 7, now call it a ... is
- PERVERSELY a native C, zero-offset array. ... Heaven help you! ... You
- simply invoke someroutine(a-1,7) ... We want to free you from the
- zero-offset thinking that C encourages ... A final liberating-point is
- that the utility file nrutil.c, listed in full in Appendix B, includes
- functions for allocating arbitrary-offset vectors of arbitrary
- lengths."
-
- Of course, nrutil.c in Appendix B uses the same WRONG trick. Please,
- realize that Press, Teukolsky, Vetterling and Flannery MAY know
- algorithms (some disagree on that too; see
- http://www.lysator.liu.se/c/num-recipes-in-c.html) but FOR SURE they
- do NOT know C.
- --
- Maurizio Loreti http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
- Un. of Padova, Dept. of Physics - Padova, Italy loreti@padova.infn.it
-